project(LocalLogClient)

# 查找 systemd 库
# 需要安装 PkgConfig库 sudo apt-get install pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(SYSTEMD REQUIRED libsystemd)

# 查找 LogCollector 库
find_package(LogCollector REQUIRED)

add_executable(LocalLogClient
    main.cpp
)

target_include_directories(LocalLogClient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# 加入systemd的include目录
target_include_directories(LocalLogClient PRIVATE ${SYSTEMD_INCLUDE_DIRS})

# 加入lib库include目录
target_include_directories(LocalLogClient PRIVATE ${LogCollector_INCLUDE_DIRS})

# 链接lib库
target_link_libraries(LocalLogClient PRIVATE LogCollector)

# 加入编译option
target_compile_options(LocalLogClient PRIVATE ${SYSTEMD_CFLAGS_OTHER})

# 链接systemd库
target_link_libraries(LocalLogClient PRIVATE ${SYSTEMD_LIBRARIES})

set(BINDIR /opt/shz/bin)

install(TARGETS LocalLogClient
    RUNTIME DESTINATION ${BINDIR}
)